#ifndef VN_TEXT_OUTPUT_H
#define VN_TEXT_OUTPUT_H

#include "bn_unordered_map.h"
#include "bn_sprite_text_generator.h"
#include "bn_string.h"
#include "bn_string_view.h"
#include "bn_vector.h"
#include "bn_sprite_ptr.h"
#include "bn_unordered_set.h"

namespace
{
    constexpr int MAX_WIDTH{38};
    constexpr int MAX_ROWS_8{4};

    constexpr int TEXT_X{-111};
    constexpr int TEXT_Y{44};
}

class text
{
    bn::sprite_text_generator* text_gnrtr;
    bn::vector<bn::sprite_ptr, MAX_WIDTH> symbols;

    //this should store indexes for first and last symbols in every line of on-screen text
    //(retrieved once via outputMultipleLines for use in typewriter output)
    bn::vector<int, MAX_ROWS_8> line_starters;
    bn::vector<int, MAX_ROWS_8> line_breakers;

    //same but for opcodes
    bn::vector<int, 10> opcode_starters;
    bn::vector<int, 10> opcode_enders;


    //text output variables to replace defines
    int text_x, text_y, max_width, max_rows;
    int line_counter;

public:
    text();
    text(bn::sprite_text_generator*);
    text(bn::string_view const&, bn::sprite_text_generator*);
    text(bn::string_view const&, bn::sprite_text_generator*, int, int, int, int);
    bool output_Typewriter(bn::string_view const &, int&, int&);
    bool output_NoEffect(bn::string_view const &);

    void outputSingleLine(bn::string_view const &);
    void outputSingleLine(int y, bn::string_view const &);
    void outputSingleLine(int x, int y, bn::string_view const &);

    //fills out index vectors for separating lines
    void breakIntoMultipleLines(bn::string_view const &);
    //coordinates for blinking cursor
    bn::fixed_point getLastSymbolCoords();

    void clear();
    //redefine all index vectors and line counter
    void redraw(bn::string_view const&);
    ~text();
};

#endif // VN_TEXT_OUTPUT_H
